package com.example.zookeeper.util;

import com.example.zookeeper.entity.Config;
import com.example.zookeeper.watch.DefaultWatchCallBack;
import org.apache.zookeeper.ZooKeeper;

import java.util.logging.Logger;

/**
 * @author Vicente
 * @version 1.0
 * @date 2020/3/8 15:09
 */
public class ConfigUtils {
    static Logger logger = Logger.getLogger("com.example.zookeeper.entity.Config");
    public static void getConfData(ZooKeeper zooKeeper){
        Config conf = new Config();
        DefaultWatchCallBack watchCallBack = new DefaultWatchCallBack();
        watchCallBack.setZooKeeper(zooKeeper);  //当前实例对象
        watchCallBack.setConf(conf);
        watchCallBack.aWait();
        while (true){
            if(conf.getConf().equals("")){
                logger.info("服务器端配置丢失...");
                watchCallBack.aWait();
            }else{
                logger.info(conf.getConf());
            }
        }
    }
}
